<div class="container-fluid">
    <div class="block-header">
        <h2>广告 > 管理网站广告</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="card">
                <div class="header">
                    <h2>管理网站广告</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success ads-settings-alert"></div>
                    <form class="ads-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="header" id="header" class="form-control" cols="30" rows="5"><?php echo Wo_GetAd('header', true);?></textarea>
                                <label class="form-label">页头 <small>(出现在导航栏正下方的所有页面上)</small></label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="sidebar" id="sidebar" class="form-control" cols="30" rows="5"><?php echo Wo_GetAd('sidebar', true);?></textarea>
                                <label class="form-label">侧边栏 <small>(出现在主页边栏的底部)</small></label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="footer" id="footer" class="form-control" cols="30" rows="5"><?php echo Wo_GetAd('footer', true);?></textarea>
                                <label class="form-label">页脚 <small>(出现在页脚之前的所有页面上)</small></label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="post_first" id="post_first" class="form-control" cols="30" rows="5"><?php echo Wo_GetAd('post_first', true);?></textarea>
                                <label class="form-label">文章 1 <small>（在文章之后加载10个文章后出现）</small></label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="post_second" id="post_second" class="form-control" cols="30" rows="5"><?php echo Wo_GetAd('post_second', true);?></textarea>
                                <label class="form-label">文章 2 <small>（在文章之后加载20个文章后出现）</small></label>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <textarea name="post_third" id="post_third" class="form-control" cols="30" rows="5"><?php echo Wo_GetAd('post_third', true);?></textarea>
                                <label class="form-label">文章 3 <small>（在文章之后加载30个文章后出现）</small></label>
                            </div>
                        </div>

                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">保存</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>
$(function() {
    var form_ads_settings = $('form.ads-settings');
    form_ads_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=update_ads',
        beforeSend: function() {
            form_ads_settings.find('.waves-effect').text('请稍后..');
        },
        beforeSubmit : function(arr, $form, options){
          delete arr[0];
          delete arr[1];
          delete arr[2];
          delete arr[3];
          delete arr[4];
          delete arr[5];
          arr.push({name:'header', value:btoa(unescape(encodeURIComponent($('#header').val())))});
          arr.push({name:'sidebar', value:btoa(unescape(encodeURIComponent($('#sidebar').val())))}); 
          arr.push({name:'footer', value:btoa(unescape(encodeURIComponent($('#footer').val())))}); 
          arr.push({name:'post_first', value:btoa(unescape(encodeURIComponent($('#post_first').val())))}); 
          arr.push({name:'post_second', value:btoa(unescape(encodeURIComponent($('#post_second').val())))}); 
          arr.push({name:'post_third', value:btoa(unescape(encodeURIComponent($('#post_third').val())))}); 
        },
        success: function(data) {
            if (data.status == 200) {
                form_ads_settings.find('.waves-effect').text('保存');
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.ads-settings-alert').html('<i class="fa fa-check"></i> 广告更新成功');
                setTimeout(function () {
                    $('.ads-settings-alert').empty();
                }, 2000);
            }
        }
    });
});
</script>